package com.apex.lottery.controller.converter;

import com.apex.lottery.controller.result.WinningRecordResult;
import com.apex.lottery.service.dto.WinningRecordDTO;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @ClassName DrawPrizeConverter
 * @Description
 * @Author ZJX
 * @Date 2025/4/24 12:48
 * @Version 1.0
 **/
public class DrawPrizeConverter {
    public static List<WinningRecordResult> convertToWinningRecordResultList(List<WinningRecordDTO> winningRecordDTOList) {
        if (CollectionUtils.isEmpty(winningRecordDTOList)){
            return List.of();
        }
        return winningRecordDTOList.stream()
                .map(winningRecordDTO -> {
                    WinningRecordResult result = new WinningRecordResult();
                    result.setWinnerId(winningRecordDTO.getWinnerId());
                    result.setWinningTime(winningRecordDTO.getWinningTime());
                    result.setPrizeName(winningRecordDTO.getPrizeName());
                    result.setPrizeTier(winningRecordDTO.getPrizeTier().getMessage());
                    result.setWinnerName(winningRecordDTO.getWinnerName());
                   return result;
        }).toList();
    }
}
